package com.harry.drawlayout_project.activities;

import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import androidx.drawerlayout.widget.DrawerLayout;

import com.harry.drawlayout_project.R;
import com.harry.drawlayout_project.base.BaseActivity;

/**
 * @author Martin-harry
 * @date 2022/1/1
 * @address
 * @Desc MainActivity
 */
public class MainActivity extends BaseActivity implements View.OnClickListener {

    private View view;
    private ImageView pull;//菜单
    private DrawerLayout drawer;
    private LinearLayout patients;
    private LinearLayout advice;
    private LinearLayout manage;
    private LinearLayout personal;
    private RelativeLayout exit;

    @Override
    protected View addContentLayout() {
        view = getLayoutInflater().inflate(R.layout.activity_main,baseLayout,false);
        return view;
    }

    protected void initView() {

    }

    protected void initData() {
        setTitle("首页");
        drawer = findViewById(R.id.drawer_layout);
        pull = findViewById(R.id.pull);
        patients = findViewById(R.id.patients);
        advice = findViewById(R.id.advice);
        manage = findViewById(R.id.manage);
        personal = findViewById(R.id.personal);
        exit = findViewById(R.id.exit);
        patients.setOnClickListener(this);
        advice.setOnClickListener(this);
        manage.setOnClickListener(this);
        personal.setOnClickListener(this);
        exit.setOnClickListener(this);
        pull.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.pull:
                drawer.openDrawer(Gravity.LEFT);
                break;
            case R.id.patients:
                Toast.makeText(this, "所有患者", Toast.LENGTH_SHORT).show();

                drawer.closeDrawer(Gravity.LEFT);
                break;
            case R.id.advice:
                Toast.makeText(this, "血糖医嘱", Toast.LENGTH_SHORT).show();

                drawer.closeDrawer(Gravity.LEFT);
                break;
            case R.id.manage:
                Toast.makeText(this, "设备管理", Toast.LENGTH_SHORT).show();

                drawer.closeDrawer(Gravity.LEFT);
                break;
            case R.id.personal:
                Toast.makeText(this, "个人中心", Toast.LENGTH_SHORT).show();

                drawer.closeDrawer(Gravity.LEFT);
                break;
            case R.id.exit:
                Toast.makeText(this, "退出登录", Toast.LENGTH_SHORT).show();
                drawer.closeDrawer(Gravity.LEFT);
                break;
        }
    }
}
